package com.navinfo.opentsp.platform.computing.dto;


import com.navinfo.opentsp.platform.location.protocol.common.LCPredictiveMaintenance;
import com.navinfo.platform.bigdata.util.EntityConvert;

public class MaintenanceEvent2Dto {
    private double mileage;               //里程
    private double speed;                   //车速
    private int clutchSwitch;           //离合器开关
    private int neutralSwitch;           //空挡开关
    private long engineTorque;        //发动机扭矩
    private long flywheelTorque;     //飞轮扭矩
    private double rotation;            //发动机转速
    private double rotationDifference1; //转速差
    private int gearPosition1;           //档位
    private double slipTime1;            //打滑时间
    private long energy1;                   //能量

    public double getMileage() {
        return mileage;
    }

    public void setMileage(double mileage) {
        this.mileage = mileage;
    }

    public double getSpeed() {
        return speed;
    }

    public void setSpeed(double speed) {
        this.speed = speed;
    }

    public int getClutchSwitch() {
        return clutchSwitch;
    }

    public void setClutchSwitch(int clutchSwitch) {
        this.clutchSwitch = clutchSwitch;
    }

    public int getNeutralSwitch() {
        return neutralSwitch;
    }

    public void setNeutralSwitch(int neutralSwitch) {
        this.neutralSwitch = neutralSwitch;
    }

    public long getEngineTorque() {
        return engineTorque;
    }

    public void setEngineTorque(long engineTorque) {
        this.engineTorque = engineTorque;
    }

    public long getFlywheelTorque() {
        return flywheelTorque;
    }

    public void setFlywheelTorque(long flywheelTorque) {
        this.flywheelTorque = flywheelTorque;
    }

    public double getRotation() {
        return rotation;
    }

    public void setRotation(double rotation) {
        this.rotation = rotation;
    }

    public double getRotationDifference1() {
        return rotationDifference1;
    }

    public void setRotationDifference1(double rotationDifference1) {
        this.rotationDifference1 = rotationDifference1;
    }

    public int getGearPosition1() {
        return gearPosition1;
    }

    public void setGearPosition1(int gearPosition1) {
        this.gearPosition1 = gearPosition1;
    }

    public double getSlipTime1() {
        return slipTime1;
    }

    public void setSlipTime1(double slipTime1) {
        this.slipTime1 = slipTime1;
    }

    public long getEnergy1() {
        return energy1;
    }

    public void setEnergy1(long energy1) {
        this.energy1 = energy1;
    }

    public static MaintenanceEvent2Dto parseProto(LCPredictiveMaintenance.MaintenanceEvent2 maintenanceEvent2){
        MaintenanceEvent2Dto maintenanceEvent2Dto = new MaintenanceEvent2Dto();
        maintenanceEvent2Dto.setMileage(maintenanceEvent2.getMileage());
        maintenanceEvent2Dto.setSpeed(maintenanceEvent2.getSpeed());
        maintenanceEvent2Dto.setClutchSwitch(maintenanceEvent2.getClutchSwitch());
        maintenanceEvent2Dto.setNeutralSwitch(maintenanceEvent2.getNeutralSwitch());
        maintenanceEvent2Dto.setEngineTorque(maintenanceEvent2.getEngineTorque());
        maintenanceEvent2Dto.setFlywheelTorque(maintenanceEvent2.getFlywheelTorque());
        maintenanceEvent2Dto.setRotation(maintenanceEvent2.getRotation());
//        maintenanceEvent2Dto.setRotationDifference1(maintenanceEvent2.getRotationDifference1());
//        maintenanceEvent2Dto.setGearPosition1(maintenanceEvent2.getGearPosition1());
//        maintenanceEvent2Dto.setSlipTime1(maintenanceEvent2.getSlipTime1());
//        maintenanceEvent2Dto.setEnergy1(maintenanceEvent2.getEnergy1());
        return maintenanceEvent2Dto;
    }

    /**
     * 解析成String拼接字符串
     * @param maintenanceEvent2
     * @return
     */
    public static String parseString(LCPredictiveMaintenance.MaintenanceEvent2 maintenanceEvent2){
        return EntityConvert.convert(
                maintenanceEvent2.getMileage(),
                maintenanceEvent2.getSpeed(),
                maintenanceEvent2.getClutchSwitch(),
                maintenanceEvent2.getNeutralSwitch(),
                maintenanceEvent2.getEngineTorque(),
                maintenanceEvent2.getFlywheelTorque(),
                maintenanceEvent2.getRotation())
//                maintenanceEvent2.getRotationDifference1(),
//                maintenanceEvent2.getGearPosition1(),
//                maintenanceEvent2.getSlipTime1(),
//                maintenanceEvent2.getEnergy1());
    ;}

    /**
     * 反解析成PB对象
     * @param str
     * @return
     */
    public static LCPredictiveMaintenance.MaintenanceEvent2 parsePB(String str){
        LCPredictiveMaintenance.MaintenanceEvent2.Builder builder = null;

        try{
            String[] revert = EntityConvert.revert(str);
            if(null!=revert && revert.length>=11){
                builder = LCPredictiveMaintenance.MaintenanceEvent2.newBuilder();
                builder.setMileage(Double.valueOf(revert[0]));
                builder.setSpeed(Double.valueOf(revert[1]));
                builder.setClutchSwitch(Integer.valueOf(revert[2]));
                builder.setNeutralSwitch(Integer.valueOf(revert[3]));
                builder.setEngineTorque(Long.valueOf(revert[4]));
                builder.setFlywheelTorque(Long.valueOf(revert[5]));
                builder.setRotation(Double.valueOf(revert[6]));
//                builder.setRotationDifference1(Double.valueOf(revert[7]));
//                builder.setGearPosition1(Integer.valueOf(revert[8]));
//                builder.setSlipTime1(Double.valueOf(revert[9]));
//                builder.setEnergy1(Long.valueOf(revert[10]));
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return builder==null? null : builder.build();
    }

}
